package com.wlt.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wlt.domain.User;
import com.wlt.mapper.UserMapper;
import com.wlt.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper userDao;

	@Override
	public List<User> list() {
		return userDao.list();
	}
	/**
	 * 登录
	 */
	@Override
	public User checkLogin(String name, String pwd) {
		User user = userDao.findByUserName(name);
		if (user != null && user.getPassword().equals(pwd)) {
			return user;
		}
		return null;
	}
	/**
	 * 注册
	 */
	@Override
	public void Regist(User user) {
		userDao.registerByUsernameAndPassword(user.getUserName(), user.getPassword());
	}
	/**
	 * 删除用户
	 */
	@Override
	public void deleteByUserId(int id) {
		userDao.deleteByUserId(id);
	}
	//增加用户
	@Override
	public void addUser(User user) {
		userDao.addUser(user.getUserName(),user.getPassword());
	}

}
